home *** CD-ROM | disk | FTP | other *** search
/ Programmer Plus 2007 / Programmer-Plus-2007.iso / Programming / XML Utilities / Professional Programmer XSL IDE / Xselerator25.msi / Data.Cab / F29120_foldltree.xsl < prev    next >
Encoding:
Extensible Markup Language  |  2001-11-04  |  2.9 KB  |  75 lines

  1. <xsl:stylesheet version="1.0" 
  2. xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
  3. >
  4.     <xsl:template name="foldl-tree">
  5.       <xsl:param name="pFuncNode" select="/.."/>
  6.       <xsl:param name="pFuncSubtrees" select="/.."/>
  7.       <xsl:param name="pA0"/>
  8.       <xsl:param name="pNode" select="/.."/>
  9.  
  10.       <xsl:choose>
  11.          <xsl:when test="not($pNode)">
  12.             <xsl:copy-of select="$pA0"/>
  13.          </xsl:when>
  14.          <xsl:otherwise>
  15.          
  16.             <xsl:variable name="vSubtrees" select="$pNode/*"/>
  17.             
  18.             <xsl:variable name="vSubTreeResult">
  19.               <xsl:call-template name="foldl-tree_">
  20.                   <xsl:with-param name="pFuncNode" select="$pFuncNode"/>
  21.                   <xsl:with-param name="pFuncSubtrees" select="$pFuncSubtrees"/>
  22.                   <xsl:with-param name="pA0" select="$pA0"/>
  23.                   <xsl:with-param name="pSubTrees" select="$vSubtrees"/>
  24.               </xsl:call-template>
  25.             </xsl:variable>
  26.  
  27.             <xsl:apply-templates select="$pFuncNode[1]">
  28.               <xsl:with-param name="arg0" select="$pFuncNode[position() > 1]"/>
  29.               <xsl:with-param name="arg1" select="$pNode/@tree-nodeLabel"/>
  30.               <xsl:with-param name="arg2" select="$vSubTreeResult"/>
  31.             </xsl:apply-templates>
  32.  
  33.          </xsl:otherwise>
  34.       </xsl:choose>
  35.     </xsl:template>
  36.     
  37.     <xsl:template name="foldl-tree_">
  38.       <xsl:param name="pFuncNode" select="/.."/>
  39.       <xsl:param name="pFuncSubtrees" select="/.."/>
  40.       <xsl:param name="pA0"/>
  41.       <xsl:param name="pSubTrees" select="/.."/>
  42.       
  43.       <xsl:choose>
  44.          <xsl:when test="not($pSubTrees)">
  45.             <xsl:copy-of select="$pA0"/>
  46.          </xsl:when>
  47.          <xsl:otherwise>
  48.           <xsl:variable name="vSubTree1Result">
  49.             <xsl:call-template name="foldl-tree">
  50.               <xsl:with-param name="pFuncNode" select="$pFuncNode"/>
  51.               <xsl:with-param name="pFuncSubtrees" select="$pFuncSubtrees"/>
  52.               <xsl:with-param name="pA0" select="$pA0"/>
  53.               <xsl:with-param name="pNode" select="$pSubTrees[1]"/>
  54.             </xsl:call-template>
  55.           </xsl:variable>
  56.           
  57.           <xsl:variable name="vRestSubtreesResult">
  58.             <xsl:call-template name="foldl-tree_">
  59.               <xsl:with-param name="pFuncNode" select="$pFuncNode"/>
  60.               <xsl:with-param name="pFuncSubtrees" select="$pFuncSubtrees"/>
  61.               <xsl:with-param name="pA0" select="$pA0"/>
  62.               <xsl:with-param name="pSubTrees" select="$pSubTrees[position() > 1]"/>
  63.             </xsl:call-template>
  64.           </xsl:variable>
  65.           
  66.             <xsl:apply-templates select="$pFuncSubtrees">
  67.               <xsl:with-param name="arg0" select="$pFuncSubtrees[position() > 1]"/>
  68.               <xsl:with-param name="arg1" select="$vSubTree1Result"/>
  69.               <xsl:with-param name="arg2" select="$vRestSubtreesResult"/>
  70.             </xsl:apply-templates>
  71.         </xsl:otherwise>
  72.       </xsl:choose>    
  73.     </xsl:template>
  74.  
  75. </xsl:stylesheet>